package com.jdy.haoduoaiteacher.util;

import android.content.Context;
import android.content.ContextWrapper;
import android.content.Intent;
import android.net.Uri;
import android.os.Environment;

import java.io.File;

public class PathUtil {

  private static PathUtil pathUtil;

  public static PathUtil getInstance() {

    if (pathUtil == null) {
      pathUtil = new PathUtil();
    }
    return pathUtil;
  }

  public static String getImagePath() {

    return null;
  }

  public static String getVideoPath() {
    String path = Environment.getExternalStorageDirectory().getAbsolutePath();
    path += "/haoduoaiteacher" + "/video";
    File d = new File(path);
    if (!d.exists()) {
      d.mkdir();
    }
    return path;
  }

  public static String getSpeakForYouWallpaperPath(Context context) {

    ContextWrapper cw = new ContextWrapper(context);
    // path to /data/data/yourapp/app_data/imageDir
    File directory = cw.getDir("imageDir", Context.MODE_PRIVATE);
    // Create imageDir
    File elderAvatarFile = new File(directory, "speak_for_you_wallpaper.png");
    // addToGallery(context, elderAvatarFile);
    return elderAvatarFile.getAbsolutePath();
  }

  public static String getWallPicPath(Context context) {

    ContextWrapper cw = new ContextWrapper(context);
    // path to /data/data/yourapp/app_data/imageDir
    File directory = cw.getDir("imageDir", Context.MODE_PRIVATE);
    // Create imageDir
    File elderAvatarFile = new File(directory, "wall_pic.png");
    // addToGallery(context, elderAvatarFile);
    return elderAvatarFile.getAbsolutePath();
  }

  public static String getElderAvatarPath(Context context) {

    ContextWrapper cw = new ContextWrapper(context);
    // path to /data/data/yourapp/app_data/imageDir
    File directory = cw.getDir("imageDir", Context.MODE_PRIVATE);
    // Create imageDir
    File elderAvatarFile = new File(directory, "elder_avatar.png");
    // addToGallery(context, elderAvatarFile);
    return elderAvatarFile.getAbsolutePath();

    // String path =
    // Environment.getExternalStorageDirectory().getAbsolutePath();
    // path += "/xiaoxiaoban";
    // File d = new File(path);
    // if (!d.exists()) {
    // d.mkdir();
    // }
    // path += "/elder_avatar.png";
    // return path;
  }

  public static String getBabyAvatarPath(Context context) {

    ContextWrapper cw = new ContextWrapper(context);
    // path to /data/data/yourapp/app_data/imageDir
    File directory = cw.getDir("imageDir", Context.MODE_PRIVATE);
    // Create imageDir
    File babyAvatarFile = new File(directory, "baby_avatar.png");

    // addToGallery(context, babyAvatarFile);

    return babyAvatarFile.getAbsolutePath();

    // String path =
    // Environment.getExternalStorageDirectory().getAbsolutePath();
    // path += "/xiaoxiaoban";
    // File d = new File(path);
    // if (!d.exists()) {
    // d.mkdir();
    // }
    // path += "/baby_avatar.png";
    // return path;
  }

  public static void addToGallery(Context context, File image) {
    Intent mediaScanIntent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE);
    File f = new File("file:" + image.getAbsolutePath());
    Uri contentUri = Uri.fromFile(f);
    mediaScanIntent.setData(contentUri);
    context.sendBroadcast(mediaScanIntent);
  }

}
